<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
     <meta http-equiv="content-Type" content="text/html; charset=utf-8" />
    <title>tueye发表文章-tueye发表文章-tueye专业的图片欣赏交流社区</title>
    <meta http-equiv="content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
 

<script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/script/jquery.idTabs.min.js"></script>
 	<style type="text/css">
/*主容器*/
.usual {
	background: #cee;
	color: #111;
	padding: 15px 20px;
	width: 90%;
	border: 1px solid #099;
	margin: 8px auto;
	position: absolute;
	z-index: 20;
	font-size: 12px;
}

/*选项卡*/
.divmenu {
	position: relative;
	width: 100%;
	top: 27px;
	border-bottom: 4px solid #6395c6;
	z-index: -100;
}

.usual ul {
	margin: 0;
	padding: 0;
	padding-left: 2em;
	overflow: auto; /*火狐等清理浮动*/
	_display: inline-block; /*ie6清理浮动*/
}

.usual li {
	list-style: none;
	float: left;
	margin: 0 2px;
	border: 1px solid #6395c6;
	border-bottom: none;
}

.usual ul a {
	display: block;
	padding: 6px 10px;
	text-decoration: none;
	font: 12px Arial;
	color: #FFF;
	background: #22A4C4;
	outline: none;
}

.usual ul a:hover {
	color: #00a1ff;
	background: #eff8fe;
}

.usual ul a.selected {
	color: #000;
	background: #f9f9f9;
	cursor: default;
	border-bottom: none;
}

/*tab页*/
#content {
	border: 1px solid #6395c6;
	border-top: none;
	padding: 4px;
	background: #fff;
}
</style>

 <script type="text/javascript"> 
$(function(){ 
	    
	    $('form :input').blur(function(){
	         var id = $(this).attr("id");
             $(this).removeClass("warning").parents("td")
			 .find("span.error").remove()
			 .end()
			 .find("span.ok").remove();

		     var $listItem =  $(this).parents("td").find("span:last"); 
			 //验证email和昵称
			  if( id == 'Email' ){
				if($(this).attr("value") == null || $(this).attr("value") == ''){
                      var errorMsg = '请输入登录帐号！';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
                       var okMsg = '';
                       $(this).parent().next().text(okMsg)
                       }
			 
				
			    }
			    
			     //验证密码
			 if( id == 'password1' ){
				if($(this).attr("value") == null || $(this).attr("value") == ''){
                      var errorMsg = '请输入登录密码!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
                       var okMsg = '';
                       $(this).parent().next().text(okMsg)
                       }
			 
				
			 }
			 		 
     })//end blur
  
 
 //提交，最终验证。
	$("#tijiao").bind("click", function(){
       debugger;
			$(":input").trigger('blur');
		
			var numWarning = $('.warning',$('form')).length;
			
            if(numWarning){
			    var errorFieldList = [];
                $(".warning").each(function(){
					errorFieldList.push( $(this).prev("span").text() );
				})
				
				return false;
			}  
			
			var Email = $('#Email').val();
			var password =  $('#password1').val();
			var sendData= "Email="+encodeURIComponent(Email)+"&password1="+password;
			
			$.ajax({
            type:"POST",
            url: "<%=request.getContextPath()%>/userlogin.do?action=login", 
            dataType:'html', //接受数据格式
            async: false,
            data: sendData,
            success: function(data){ 
             var obj=eval("("+data+")");  
                  if(data=='0'){ 
                    $('#Email').parent().next().html("<font color='red'>您输入的用户名有误，请重新输入!</font>");
                  }else if(data=='2'){
                    //显示在验证码后面
                    $('#password1').parent().next().html("<font color='red'>您输入的密码有误，请重新输入，请注意大小写!</font>");
                  }else if(obj.target == '1'){
                    window.location.reload();
                   }
                }
			
			,
           error:function(data){
             alert(data);
           }
	
	})
	  
	 
		 })
		
		    
		 
	})
  </script>
	</head>	
	<body> 
		<div id="usual1" class="usual">
			<div class="divmenu"></div>
			<ul>
				<li>
					<a class="selected" href="#tab1">登录</a>
				</li>
				<li>
					<a href="#tab2">注册</a>
				</li>
				　
			</ul>
			<div id="content">
				<div id="tab1">
				　　 <form method="post" action="" name="userlogin" id="userlogin" >
						<table>
						 <tr><td colspan="2">
						 </td></tr>
						 <tr><td width="20%"  align="right">
						  Email:
						 </td><td align="left" width="30%"><input type="text" name="Email" id="Email"/></td><td class="regtip" align="right"></td></tr>
						  <tr><td width="20%"  align="right">
						 &nbsp;
						 </td><td align="left" width="30%"><font color="gray">你可用email或昵称登录
						 </font></td></tr>
						  
						 <tr><td  width="20%" align="right">
						   密码:
						 </td><td align="left"><input type="password"  name="password" id="password1" value=""/></td><td class="regtip"></td></tr>
					 
						  <tr><td  width="20%" align="right">
						   &nbsp;
						 </td><td align="left"> <input type="checkbox" id="check" checked="checked" /><font color="gray"> 一个月之内免登录</font></td><td class="regtip"></td></tr>
						 
						 <tr> <td colspan="3" align="center"><input type="button"  id="tijiao" value="登&nbsp;录" /></td></tr>
						</table>
	               </form>
					
				</div>
				<div id="tab2">
			　　　   <a href="javascript:rr();" >转向注册页</a>
					
				</div>　
			</div>
		</div>
		<script type="text/javascript">    
       $("#usual1 ul").idTabs();    
       function rr(){
          window.open('<%=path %>/pages/topics/usermanager/register.jsp');
          window.location.reload();
       }
</script>
	</body>
</html>

